/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#include <sqlite3.h>
#include <stdio.h>
#include <Elementary.h>

#ifndef HEADER_FILE_H
#define HEADER_FILE_H

sqlite3 *launcher, *launcher_thread;

void restore_state(void);
void first_run(void);
void save_state(void);
void add_hs_items(Evas_Object *win, Evas_Object *bx, Evas_Object *bt, int i);
int get_apps(char *cat);
void populate_app_list(Evas_Object *list);
void populate_cat_list(Evas_Object *lis);
void del_category(char * cat);
void add_category(char * cat);
void ren_category(char *old, char *new_nm);
void update_category(char *name, char *cate);
void add_toolbar_items(void);
void add_toolbar_home_items(Evas_Object *q_tb);
void refresh_app_data(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path);
void populate_seq_list (Evas_Object *li, char *type);
void change_seq(Evas_Object *li);
void rescan_apps(void);
void match_call_names(void);
void get_opim_data(void);
void commit_transaction(void);
void begin_transaction(void);
void update_calls_timestamp(void);
void update_sms_timestamp(void);
void match_sms_names(void);
int get_contacts_count_db(void);
void cat_launcher(void);
void get_opimd_data(void);

extern Elm_Genlist_Item_Class itc_seq_list, itc_list, itc_log, itc_conv, itc2, itc_contact, itc_con_cat, itc_sms_rec;
extern Elm_Genlist_Item_Class notify_itc;
extern Evas_Object *toolbar, *win, *log_list, *lb, *conv_list, *contact_list, *win_sms, *conv_list, *vbox_sms;
extern Evas_Object *contact_toolbar, *contact_win, *id, *show_apps_win;
extern Elm_Toolbar_Item *tb_item, *cat_tb_item;
extern int int_sms, int_log, int_con, no_apps, show_c_no, bb_count;
extern char icon[200][255], path[200][255], name[200][255], launcher_dir[255], wall_path[255], cur_cat[255];
extern char icon_home[8][255], path_home[8][255], name_home[8][255];
extern char app_sms[255], app_calls[255], f_date[255], f_time[255], loc[255], con_path[255], con_cat[255];
extern char national_prefix[10], country_code[10], area_code[10], cb_subs[255], hs_add[255], log_type[25], *add_sms_path;
extern double s_ts, c_ts;

extern void select_category(void *data, Evas_Object *obj, void *event_info);
extern void set_category(void *data, Evas_Object *obj, void *event_info);
extern void set_button_clicked(void *user_data, Evas_Object *obj, const char *em, const char *src); //(void *data, Evas_Object *obj, void *event_info);
extern void edit_cat(void *data, Evas_Object *obj, void *event_info);
extern void show_noti(void *data, Evas_Object *obj, void *event_info);
extern void get_contacts_data(void);
extern void get_sms_data(void);
extern void get_calls_data(void);
extern void my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info);
extern void my_anchorblock_bt(void *data, Evas_Object *obj, void *event_info);
extern void create_opim_tables(void);
extern void del_sms(char *path);
extern void show_cat_contacts(void *data, Evas_Object *obj, void *event_info);
extern void set_con_category(char *cat);
extern void update_contacts_opim(void);
extern void reply_sms(void *data, Evas_Object *obj, void *event_info);
extern void icon_clicked(void *data, Evas_Object *obj, void *event_info);
extern void icon_home_clicked(void *data, Evas_Object *obj, void *event_info);
extern void clear_suspend_timer(void);
extern void set_wake_timer(int tim);
extern void show_notifications(void);

void popup_message(char *message, char *msg, int butt_state);

FILE *fil;

typedef struct{
	char app[255];
	char cat[255];
}  _Cat;
extern _Cat *Cat;

typedef struct{
	char num[255];
	char name[255];
	int dur;
	int icon;
	char timestamp[255];
	char path[255];
}  _Log;
extern _Log Log[30];

typedef struct _WinList
{
   Evas_Object *win;
   Evas_Object *li;
} Winlist;

typedef struct {
	char path[255];
	int type;
} _dir;

typedef struct {
	char direction[255];
	char sender[255];
	char recipient[255];
	int timestamp;
	char content[510];
	char path [255];
	int read;
	int combined;
	int sent;
} _sms_data;

typedef struct {
	char peer[255];
	char path[255];
	double timestamp;
	char direction[5];
	int duration;
	int ans;
	int replied;
	int new_call;
} _call_data;

typedef struct {
	char sender[255];
	char name[255];
	char timestamp[255];
	int dir;
	int count;
} _conv;
extern _conv *conv;

typedef struct {
	Evas_Object *ic;
	Evas_Object *bb;
	Evas_Object *fwd_bt;
	Evas_Object *ret_bt;
	Evas_Object *del_bt;
	Evas_Object *en;
	char path[255];
	char content[510]; //arbitary limit of 510 char (3 parts + 30 chars)
	int from;
	time_t stamp;
} _sms_re;
//data needed for sending sms's
extern _sms_re Re;

typedef struct{
	char name[255];
	char p_no[255];
}  _con_sms;
//array of contacts for fwd/mult recipients
extern _con_sms *Con_Sms; 

typedef struct {
	char name[255];
	char phone[255];
	char path[255];
	char email[255];
	char bday[255];
	char anniv[255];
	char cat[255];
	char type[255];
	char time[255];
	int out;
} _contact;
extern _contact *Contact;

typedef struct {
	Evas_Object *li;
	char type[255];
} _act_data;

typedef struct {
	Evas_Object *name_en;
	Evas_Object *num_en;
	char action[255];
	char path[255];
} _add_edit_con;

typedef struct {
	char name[255];
	char num[255];
	char path[255];
	char action[255];
} _act_element;
#endif

extern void del_single_sms(_sms_re *bb);
_sms_re *sms_bb;
